/*
 * @Author: JohnYang
 * @Date: 2020-08-25 21:25:40
 * @LastEditors: JohnYang
 * @LastEditTime: 2020-11-01 20:23:15
 */
import http from "@/utils/request";
export * from "./employee";
export * from "./compensate";
export * from "./import";

import { normalType, secondHandType } from "@/config";

export function getCarList({
  pageSize,
  pageNum,
  type,
  userName,
  region,
  frameNum,
  dealerName,
  contractNumber,
  start,
  end
}) {
  return http({
    url: "/index/index/list",
    method: "post",
    data: {
      type: type === "normal" ? normalType : secondHandType,
      pageSize,
      offset: pageNum,
      start,
      end,
      userName,
      region,
      dealerName,
      frameNum,
      contractNumber
    }
  });
}

export function deleteCar({ ids, type }) {
  return http({
    url: "/index/index/delete",
    method: "post",
    data: {
      id: ids,
      type: type == "normal" ? normalType : secondHandType
    }
  });
}

export function saveCar(model) {
  let { type, ...others } = model;
  return http({
    url: "/index/index/save",
    method: "post",
    data: {
      ...others,
      type: type == "normal" ? normalType : secondHandType
    }
  });
}

export function getCar(id, type) {
  return http({
    url: "/index/index/detail",
    method: "post",
    data: {
      id,
      type: type == "normal" ? normalType : secondHandType
    }
  });
}

export function uploadImg(data) {
  return http.post("/index/index/upload", data);
}

export function getConfig() {
  return http.get("/index/login/config");
}

export function downloadPdf({ type, id }) {
  return http.post("/index/index/download", {
    type,
    id
  });
}

export function auditCar({ id, type, approve }) {
  return http.post("/index/index/approve", {
    type,
    id,
    approve
  });
}
